<%@ Page Language="C#" MasterPageFile="~/MasterPageMcSigAdmin.master" AutoEventWireup="true"
    CodeFile="RecursosIVAConceptos.aspx.cs" Inherits="RecursosIVAConceptos" Title="Untitled Page" %>

<%@ Register Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
    Namespace="System.Web.UI" TagPrefix="asp" %>
<%@ Register assembly="DevExpress.Web.v12.2, Version=12.2.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxGridView.Export" tagprefix="dx" %>
<%@ Register Assembly="eWorld.UI" Namespace="eWorld.UI" TagPrefix="ew" %>
<%@ Register Assembly="Anthem" Namespace="Anthem" TagPrefix="anthem" %>
<%@ Register Assembly="DevExpress.Web.v12.2, Version=12.2.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxGridView" TagPrefix="dxwgv" %>
<%@ Register Assembly="DevExpress.Web.v12.2, Version=12.2.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxEditors" TagPrefix="dxe" %>
<%@ Register Assembly="UsrControls" Namespace="UsrControls" TagPrefix="cc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">

    <script language="javascript" type="text/javascript">
    
    function button1_PreCallBack()
    {
        if(confirm("Esta seguro que desea enviar este proyecto a Planes y Programas"))
        {
         document.getElementById('ctl00_ContentPlaceHolder1_btnEnviarPlanesProgramas').disabled = true;
         return true;
        }
        else
        return false;    
    }
    
    function button1_PostCallBack(button) 
    {
	document.getElementById('ctl00_ContentPlaceHolder1_btnEnviarPlanesProgramas').disabled = false;
    }

    function button1_CallBackCancelled(button) {
	    alert('La operacion fue cancelada!');
    }


    function btnConceptoFaborable_PreCallBack()
    {
        if(confirm("Esta seguro de cambiar el estado y enviar un correo con concepto favorable de este proyecto"))
        {
         document.getElementById('ctl00_ContentPlaceHolder1_btnConceptoFaborable').disabled = true;
         return true;
        }
        else
        return false;    
    }
    
    function btnConceptoFaborable_PostCallBack(button) 
    {
	document.getElementById('ctl00_ContentPlaceHolder1_btnConceptoFaborable').disabled = false;
    }
    
    
    function btnConceptoDesfaborable_PreCallBack()
    {
        if(confirm("Esta seguro de cambiar el estado y enviar un correo con concepto desfavorable de este proyecto"))
        {
         document.getElementById('ctl00_ContentPlaceHolder1_btnConceptoDesfaborable').disabled = true;
         return true;
        }
        else
        return false;    
    }
    
    function btnConceptoDesfaborable_PostCallBack(button) 
    {
	document.getElementById('ctl00_ContentPlaceHolder1_btnConceptoDesfaborable').disabled = false;
    }
  

    
    function OnGridSelectionChanged() {
    var counter = document.getElementById("selCount");
    if(counter != null) 
    setInnerText(counter, ctl00_ContentPlaceHolder1_ASPxGridViewCDPs.GetSelectedRowCount().toString());
    ctl00_ContentPlaceHolder1_ASPxGridViewCDPs.GetSelectedFieldValues('FPR_ENTIDAD_TERRITORIAL_COFINANCION', OnGridSelectionComplete);
}
function OnGridSelectionComplete(values) {
    selList.BeginUpdate();
    selList.ClearItems();
    for(var i = 0; i < values.length; i ++) {
        selList.AddItem(values[i]);
    }
    selList.EndUpdate();
}
function setInnerText(element, text) { 
    if(typeof element.textContent != 'undefined') { 
        element.textContent = text; 
    } 
    else if (typeof element.innerText != 'undefined') { 
        element.innerText = text; 
    } 
    else if (typeof element.removeChild != 'undefined') { 
        while (element.hasChildNodes()) { 
            element.removeChild(element.lastChild); 
        } 
        element.appendChild(document.createTextNode(text)); 
    } 
}

function confirmEdit()
{
var counter = ctl00_ContentPlaceHolder1_ASPxGridViewCDPs.GetSelectedRowCount();

if (counter > 1)
    {
    counter = 0;
        alert("Debe seleccionar un solo registro");
        return(false);
    }
    else if (counter == 1)
    {
    counter = 0;
        return(true);
    }
    else if (counter == 0)
    {
    counter = 0;
    alert("Debe seleccionar al  menos un registro");
        return(false);
    }
}
function delete_PreCallBack(button) 
{
var counter = ctl00_ContentPlaceHolder1_ASPxGridViewCDPs.GetSelectedRowCount();

if (counter > 0)
    {
        return confirm ('Esta seguro de eliminar los registros seleccionados?')
    }
  alert("Debe seleccionar por lo menos un registro");
    return(false);
  
}

function confirmDelete () 
{ 
		var frm;
		
		if (arguments.length > 0)
		{
			frm = arguments[0];
		}
		else
		{
			frm =document.forms[0];
		}



    // loop through all elements
    for (i=0; i<frm.length; i++) 
    {
        // Look for our checkboxes only
        if (frm.elements[i].name.indexOf("chkId") !=-1) 
        {
            // If any are checked then confirm alert, otherwise nothing happens
            if(frm.elements[i].checked) 
            {
                return confirm ('Esta seguro de eliminar los registros seleccionados?')
            }
        }
    }
    alert("Debe seleccionar por lo menos un registro");
    return(false);
}
    </script>

    <h1 class="iva">
        Recursos IVA Conceptos</h1>
    <anthem:ValidationSummary ID="ValidationSummary1" runat="server" AutoUpdateAfterCallBack="True" />
    <anthem:Label ID="lblMensaje" runat="server" AutoUpdateAfterCallBack="True" UpdateAfterCallBack="True"></anthem:Label>
    <p class="bt-space10">
        <asp:Label ID="lblInstruccion" runat="server" Text="Para agregar un Concepto, por favor agregar  el archivo, la descripcion  y a  continuacion pulse sobre el boton Guardar."
            CssClass="instruccion"></asp:Label></p>
    <div class="toolbar">
        <asp:ImageButton ID="btnRegresar" CssClass="regresar" runat="server" CausesValidation="False"
            ImageUrl="~/Imagenes/bt-regresar.gif" OnClick="btnRegresar_Click" />
        <cc1:WccAcciones ID="WccAcciones1" runat="server" AddCausesValidation="True" AddEnableCallBack="True"
            ArchiveVisible="False" AuditVisible="False" DeclineVisible="False" DeleteEnableCallBack="True"
            PublishVisible="False" UpdateCausesValidation="True" UpdateEnableCallBack="True"
            UpdateAutoUpdateAfterCallBack="true" ValidateVisible="False" AddAutoUpdateAfterCallBack="True"
            DeleteAutoUpdateAfterCallBack="True" UpdatePreCallBackFunction="return confirmEdit();"
            AddPreCallBackFunction="return confirmEdit();" OnPublish_OnClick="WccAcciones1_Publish_OnClick" />
        <anthem:Button ID="btnConceptoFaborable" runat="server" OnClick="btnConceptoFaborable_Click"
            Text="Favorable" EnabledDuringCallBack="False" TextDuringCallBack="Guardando por favor espere !!" CssClass="tab-inactivo" PreCallBackFunction="btnConceptoFaborable_PreCallBack" PostCallBackFunction="btnConceptoFaborable_PostCallBack" AutoUpdateAfterCallBack="True" CallBackCancelledFunction="button1_CallBackCancelled" />
        <anthem:Button ID="btnEnviarPlanesProgramas" runat="server" OnClick="btnEnviarPlanesProgramas_Click"
            Text="Enviar a Planes y Programas" Width="193px" EnabledDuringCallBack="False" TextDuringCallBack="Guardando por favor espere !!" CssClass="tab-inactivo" PreCallBackFunction="button1_PreCallBack" AutoUpdateAfterCallBack="True" CallBackCancelledFunction="button1_CallBackCancelled" PostCallBackFunction="button1_PostCallBack" />
        <anthem:Button ID="btnConceptoDesfaborable" runat="server" Text="Desfavorable" OnClick="btnConceptoDesfaborable_Click" EnabledDuringCallBack="False" TextDuringCallBack="Guardando por favor espere !!" CssClass="tab-inactivo" PreCallBackFunction="btnConceptoDesfaborable_PreCallBack" CallBackCancelledFunction="button1_CallBackCancelled" PostCallBackFunction="btnConceptoDesfaborable_PostCallBack" />
    </div>
    <table class="forma">
        <tr>
            <td class="campo" style="width: 20%">
                Archivos</td>
            <td>
                Los archivos Adjuntos no pueden superar las 4 Megas
                <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true">
                </asp:ScriptManager>
                <dxwgv:ASPxGridView ID="gridImagenes" runat="server" CssFilePath="~/App_Themes/PlasticBlue/{0}/styles.css"
                    CssPostfix="PlasticBlue" AutoGenerateColumns="False" DataSourceID="SqlDataSource1"
                    KeyFieldName="IPC_ID" Width="100%" OnRowDeleting="gridImagenes_RowDeleting" EnableCallBacks="False"
                    OnRowValidating="gridImagenes_RowValidating">
                    <Images SpriteCssFilePath="~/App_Themes/PlasticBlue/{0}/sprite.css">
                        <LoadingPanelOnStatusBar Url="~/App_Themes/PlasticBlue/GridView/gvLoadingOnStatusBar.gif">
                        </LoadingPanelOnStatusBar>
                        <LoadingPanel Url="~/App_Themes/PlasticBlue/GridView/Loading.gif">
                        </LoadingPanel>
                    </Images>
                    <Styles CssFilePath="~/App_Themes/PlasticBlue/{0}/styles.css" CssPostfix="PlasticBlue">
                        <Header ImageSpacing="10px" SortingImageSpacing="10px">
                        </Header>
                      
                    </Styles>
                    <Columns>
                        <dxwgv:GridViewCommandColumn VisibleIndex="0" Width="100px">
                            <EditButton Visible="True" Text="Editar">
                            </EditButton>
                            <NewButton Visible="True" Text="Nuevo">
                            </NewButton>
                            <DeleteButton Visible="True" Text="Borrar">
                            </DeleteButton>
                            <UpdateButton Text="Guardar">
                            </UpdateButton>
                        </dxwgv:GridViewCommandColumn>
                        <dxwgv:GridViewDataTextColumn FieldName="IPC_ID" ReadOnly="True" Visible="False"
                            VisibleIndex="1">
                            <EditFormSettings Visible="False" />
                        </dxwgv:GridViewDataTextColumn>
                        <dxwgv:GridViewDataTextColumn FieldName="IPI_ID" VisibleIndex="1" Visible="False">
                            <EditItemTemplate>
                                <dxe:ASPxTextBox ID="txtspz" runat="server" Width="170px" Value='<%# StrIpiId%>' />
                            </EditItemTemplate>
                            <PropertiesTextEdit EnableClientSideAPI="True">
                            </PropertiesTextEdit>
                        </dxwgv:GridViewDataTextColumn>
                        <dxwgv:GridViewDataTextColumn VisibleIndex="1" Width="200px">
                            <EditItemTemplate>
                                <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="conditional">
                                    <Triggers>
                                        <asp:PostBackTrigger ControlID="UploadBtn" />
                                    </Triggers>
                                    <ContentTemplate>
                                        <table>
                                            <tr>
                                                <td colspan="2">
                                                    <asp:FileUpload ID="FileUpload1" runat="server" Width="270px" />
                                                    <asp:Button ID="UploadBtn" runat="server" Text="Subir Archivo" OnClick="UploadBtn_Click" />
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>
                                                    <asp:Label ID="Label1" runat="server" BackColor="#FFFF80"></asp:Label>
                                                </td>
                                                <td align="right" colspan="2">
                                                </td>
                                            </tr>
                                        </table>
                                    </ContentTemplate>
                                </asp:UpdatePanel>
                            </EditItemTemplate>
                        </dxwgv:GridViewDataTextColumn>
                        <dxwgv:GridViewDataTextColumn Caption="Concepto" FieldName="SIP_DESCRIPCION" VisibleIndex="2"
                            Width="300px">
                        </dxwgv:GridViewDataTextColumn>
                        <dxwgv:GridViewDataTextColumn Caption="Nombre" FieldName="SIP_NOMBRE" VisibleIndex="3"
                            ReadOnly="True" Width="200px">
                            <EditItemTemplate>
                                <dxe:ASPxTextBox ID="txtNombre" runat="server" Width="170px" Value='<%# Bind("SIP_NOMBRE") %>' />
                            </EditItemTemplate>
                        </dxwgv:GridViewDataTextColumn>
                    </Columns>
                    <Templates>
                        <PreviewRow>
                            <table style="border: none">
                                <tbody>
                                    <tr>
                                        <td style="width: 20%; border: none; color: Black">
                                            <a target=_blank href="DocumentosRecursosIva/DocumentosPlanInversion/<%#Eval("SIP_NOMBRE")%>">
                                                <%#Eval("SIP_NOMBRE")%>
                                            </a>
                                        </td>
                                    </tr>
                                </tbody>
                            </table>
                        </PreviewRow>
                    </Templates>
                    <SettingsPager ShowDefaultImages="False">
                        <AllButton Text="All">
                        </AllButton>
                        <NextPageButton Text="Next &gt;">
                        </NextPageButton>
                        <PrevPageButton Text="&lt; Prev">
                        </PrevPageButton>
                    </SettingsPager>
                    <Settings ShowFooter="True" ShowGroupFooter="VisibleIfExpanded" ShowPreview="True" />
                    <SettingsEditing Mode="Inline" />
                    <ImagesFilterControl>
                        <LoadingPanel Url="~/App_Themes/PlasticBlue/Editors/Loading.gif">
                        </LoadingPanel>
                    </ImagesFilterControl>
                    <StylesEditors>
                        <CalendarHeader Spacing="11px">
                        </CalendarHeader>
                        <ProgressBar Height="25px">
                        </ProgressBar>
                    </StylesEditors>
                </dxwgv:ASPxGridView>
                <asp:TextBox ID="txtIdentificador" Visible="false" runat="server" Width="879px"></asp:TextBox>
                <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:MCSIGConnectionString %>"
                    DeleteCommand="DELETE FROM [IVA_PLAN_INVERSION_CONCEPTOS] WHERE [IPC_ID] = @IPC_ID"
                    InsertCommand="INSERT INTO [IVA_PLAN_INVERSION_CONCEPTOS] ([IPI_ID], [SIP_NOMBRE], [SIP_DESCRIPCION]) VALUES (@IPI_ID, @SIP_NOMBRE, @SIP_DESCRIPCION)"
                    SelectCommand="SELECT [IPC_ID], [IPI_ID], [SIP_NOMBRE], [SIP_DESCRIPCION] FROM [IVA_PLAN_INVERSION_CONCEPTOS] WHERE ([IPI_ID] = @IPI_ID)"
                    UpdateCommand="UPDATE [IVA_PLAN_INVERSION_CONCEPTOS] SET [IPI_ID] = @IPI_ID, [SIP_NOMBRE] = @SIP_NOMBRE, [SIP_DESCRIPCION] = @SIP_DESCRIPCION WHERE [IPC_ID] = @IPC_ID">
                    <SelectParameters>
                        <asp:ControlParameter ControlID="txtIdentificador" Name="IPI_ID" PropertyName="Text"
                            Type="Decimal" />
                    </SelectParameters>
                    <DeleteParameters>
                        <asp:Parameter Name="IPI_ID" Type="Decimal" />
                    </DeleteParameters>
                    <UpdateParameters>
                        <asp:Parameter Name="SPZ_ID" Type="Decimal" />
                        <asp:Parameter Name="SIP_NOMBRE" Type="String" />
                        <asp:Parameter Name="SIP_DESCRIPCION" Type="String" />
                        <asp:Parameter Name="IPI_ID" Type="Decimal" />
                    </UpdateParameters>
                    <InsertParameters>
                        <asp:ControlParameter ControlID="txtIdentificador" Name="IPI_ID" PropertyName="Text"
                            Type="Decimal" />
                        <asp:Parameter Name="SIP_NOMBRE" Type="String" />
                        <asp:Parameter Name="SIP_DESCRIPCION" Type="String" />
                    </InsertParameters>
                </asp:SqlDataSource>
            </td>
        </tr>
    </table>
</asp:Content>
